package com.game.thrones.domain.IdEntity;

import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import java.util.Date;

/**
 * 继承IdEntityAuto的对象，在创建或更新前自动加入时间戳
 * 
 * @author sunyang
 *
 */
public class IdEntityExternalListener {

	@PrePersist
	public void prePersist(IdEntityExternal idEntityExternal) {
		Date now = new Date();
		idEntityExternal.setCreateTime(now);
		idEntityExternal.setModifyTime(now);
	}

	@PreUpdate
	public void preUpdate(IdEntityExternal idEntityExternal) {
		Date now = new Date();
		idEntityExternal.setModifyTime(now);
	}
}
